package com.troila.cloud.simplify.repository;

import java.util.List;


import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.troila.cloud.simplify.model.SAnswer;

public interface UserRepository extends JpaRepository<SAnswer, Integer> {
	
	
	/*Page<SAnswer> findAll(Pageable pageable);
	
	List<SAnswer> findAll();
	
	@Query(" from Account act"
			+ " where act.ifAdmin = ?1 and act.status= '0' ")
	List<SAnswer> findAll(String status);
	
	@Query("select act.id as id " + 
			" from Account act,Order ord "
			+ " where act.userId = ord.userId and act.userId = ?1 and act.accountId = ?2 and ord.productId = ?3 ")
	List<SAnswer> getUserListByUserIdAndAcountId(String userId,String accountId,String productId);
	
	@Query("select act.id as id ,act.accountId as accountId " + 
			" from Account act,Order ord "
			+ " where act.userId = ord.userId and act.userId = ?1 and act.password = ?2 and ord.productId = ?3 ")
	List<SAnswer> getUserInfoByUserIdAndPsdAndPdtId(String userId,String psd,String productId);

	@Query("select act.id as id " + 
			" from Account act,Order ord "
			+ " where act.userId = ord.userId and act.accountId = ?1 and ord.productId = ?2 ")
	List<SAnswer> getUserInfoByAccountIdAndPruductId(String accountId,String pruductId);
	
	@Query(" from Account act"
			+ " where act.accountId = ?1 and act.status= '0' ")
	List<SAnswer> getUserInfoByAccountId(String accountId);
	
	@Query("from Account act "
			+ " where act.ifAdmin=?3 and act.userId = ?1 and act.password = ?2 ")
	List<SAnswer> getUserInfoByUserIdAndPsdBg(String userId,String password,String ifAdmin);
	
	
	@Modifying
	@Query("update Account set status=?1 where id=?2 ")
	void updateAccountStatusById(Integer status,Integer id);
	
	<S extends SAnswer> Page<S> findAll(Example<S> arg0, Pageable arg1);

	@Query("from Account act "
			+ " where act.status ='0' and act.ifAdmin='0' and act.userId = ?1 ")
	List<SAnswer> getUserInfoByUserId(String userId);
	
	@Modifying
	@Query("update Account set password=?1 where userId=?2 ")
	Integer updateUserPsdByUserId(String password,String userId);
	
	Page<SAnswer> findAll(Specification<SAnswer> spec, Pageable pageable);*/
}
